package interfaces

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"ruoyi/application"
	"ruoyi/domain/entity/monitor"
)

type Service struct {
	service   application.ServiceAppInterface
	operation application.OperationLogAppInterface
}

//captcha constructor
func NewService(service application.ServiceAppInterface, operation application.OperationLogAppInterface) *Service {
	return &Service{
		service:   service,
		operation: operation,
	}
}

func (s *Service) ServerData(context *gin.Context) {
	var operLog = monitor.SysOperLog{
		Title:        "操作日志",
		BusinessType: monitor.BusinessTypeAdd,
		Method:       "GET",
		OperatorType: monitor.OperatorTypeAdmin,
		OperParam:    "",
		JsonResult:   "",
		Status:       "0",
		ErrorMsg:     "",
	}
	s.operation.OperationLogAdd(context, operLog)
	var server = s.service.GetServerInfo(context)
	context.JSON(http.StatusOK, gin.H{
		"msg":  "操作成功",
		"code": http.StatusOK,
		"data": server,
	})
}
